<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class dashboard extends My_Controller
{
	function __construct()	{		parent::__construct();				$this->load->model('mdl_dashboard', 'dashboard'); 		$this->load->library(array('fungsi','pquery'));			}

	
	function index()
	{
		$this->open();		
		# config pagination
		$config['base_url'] = base_url().'index.php/dashboard/index/';	
		$this->pagination->initialize($config);	
		# end config pagination
		$year = date('Y')-1;				$data['anggaran'] = $this->dashboard->anggaran($year);
		$rows_anggaran = $data['anggaran']->row();		$data['anggaran_hasil']=$rows_anggaran->selisih;				$data['pendapatan'] = $this->dashboard->pendapatan($year);		$rows_pendapatan = $data['pendapatan']->row();		$data['pendapatan_hasil']=$rows_pendapatan->jml_kredit;				$data['pengeluaran'] = $this->dashboard->pengeluaran($year);		$rows_pengeluaran = $data['pengeluaran']->row();		$data['pengeluaran_hasil']=$rows_pengeluaran->jml_debet;				$data['piutang'] = $this->dashboard->piutang($year);		$rows_piutang = $data['piutang']->row();		$data['piutang_hasil']=$rows_piutang->piutang;		
		# load view		$this->load->helper(array('url','fusioncharts')) ;                $graph_swfFile      = base_url().'asset/admin/js/chart/flash/Column3D.swf' ;        $graph_caption      = 'Chart' ;        $graph_numberPrefix = 'Rp.' ;        $graph_title        = 'Penjualan Produk' ;        $graph_width        = 500 ;        $graph_height       = 300;        // Store Name of Products        $arrData[0][1] = "Anggaran";        $arrData[1][1] = "Pemasukan";//pendapatan        $arrData[2][1] = "Realisasi";//pengeluaran        $arrData[3][1] = "Piutang";         //Store sales data		/*        $arrData[0][2] = $data['anggaran_hasil'];        $arrData[1][2] = $data['pendapatan_hasil'];        $arrData[2][2] = $data['pengeluaran_hasil'];        $arrData[3][2] = $data['piutang_hasil']; 		*/		$arrData[0][2] = '0';        $arrData[1][2] = '0';        $arrData[2][2] = '0';        $arrData[3][2] = '0';         $strXML = "<graph caption='".$graph_caption."' numberPrefix='".$graph_numberPrefix."' formatNumberScale='0' decimalPrecision='0'>";        //Convert data to XML and append		foreach ($arrData as $arSubData) 		{            $strXML .= "<set name='" . $arSubData[1] . "' value='" . $arSubData[2] . "' color='".getFCColor()."' />";        }				//Close <chart> element		$strXML .= "</graph>";                $data['graph']  = renderChart($graph_swfFile, $graph_title, $strXML, "div" , $graph_width, $graph_height);        //$this->load->view('chart_view',$data) ;
		$this->load->view('dashboard/dashboard',$data);
		
		$this->close();
	}
	
}